﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;

namespace ASmile.Helpers
{
    public class ColorHelper
    {
        /// <summary>
        /// rgb 转换为color
        /// </summary>
        public static Color RgbToColor(int rgb)
        {
            int r = 0xFF & rgb;
            int g = 0xFF00 & rgb;
            g >>= 8;
            int b = 0xFF0000 & rgb;
            b >>= 16;
            return Color.FromArgb(r, g, b);
        }

        public static uint ColorToRgb(Color color)
        {
            return ((uint)color.B << 16) | (ushort)((color.G << 8) | color.R);

            //return (color.B << 16) | (ushort)((color.G << 8) | color.R);
        }

        public static uint ArgbToRgb(int argb)
        {
            var c = Color.FromArgb(argb);
            return ColorToRgb(c);
        }
    }
}